package com.util;

import java.util.HashMap;
import java.util.Map;

public class PayRequestParameter {
	public static  Map<String, String> getRequestParameter(String requestStr)
	{
		Map<String, String> map = null;
		String[] ss = requestStr.trim().split("&");
		if(ss.length>0)
		{
			map = new HashMap<String, String>();
			for (String s : ss) {
				String[] ss1 = s.split("=", 2);
				map.put(ss1[0], ss1[1]);
			}
		}
		return map;
	}
	public static String checkRequestParameter(Map<String, String> map)
	{
		if(map.get("imsi") == null || map.get("imsi").length()<=0)
		{
			return PayErrorCode.RESPONSE_PARAM_ERROR;
		}
		if(map.get("version") == null || map.get("version").length()<=0)
		{
			return PayErrorCode.RESPONSE_PARAM_ERROR;
		}
		if(map.get("package") == null || map.get("package").length()<=0)
		{
			return PayErrorCode.RESPONSE_PARAM_ERROR;
		}
		if(map.get("appid") == null || map.get("appid").length()<=0)
		{
			return PayErrorCode.RESPONSE_PARAM_ERROR;
		}
		if(map.get("fee") == null || map.get("fee").length()<=0)
		{
			return PayErrorCode.RESPONSE_PARAM_ERROR;
		}
		if(map.get("kpay_versioncode") == null || map.get("kpay_versioncode").length()<=0)
		{
			return PayErrorCode.RESPONSE_PARAM_ERROR;
		}
		if(map.get("mobile")!=null && map.get("mobile").trim().equals("0"))
		{
			map.put("mobile", "");
		}
		return "";
	}
}
